/**
 * 首页接口
 */
import base from './base'
export default class index extends base {
  // 授权手机号解码
  static getPhone(wxCode, encryptedData, iv, sessionKey, openId) {
    const url = this.urlMap.zhouyu + '/phone.post'
    const param = {
      wxCode,
      encryptedData,
      iv,
      sessionKey,
      openId
    }
    return this.post(url, param)
  }
  // 获取验证吗
  static getCaptcha (params) {
    const url = this.urlMap.zhouyu + '/v2/message/message.send/' + params
    return this.get(url)
  }
  // 用户登录
  static userLogin (params) {
    const url = this.urlMap.zhouyu + `/v3/user/user.login`
    return this.post(url, params)
  }
  // 学习包列表
  static indexPackage(params) {
    let url = this.urlMap.zhouyu + `/indexPackage.post/`
    return this.post(url, params)
  }
  // 学习包学习记录
  static collPackageRecord (params) {
    let url = this.urlMap.zhouyu + `/collPackageRecord.add`
    return this.post(url, params)
  }
  // 搜索页面
  static Search(colPackageIds, packageName, pageNumber, pageSize = 10) {
    let url = this.urlMap.zhouyu + `/indexPackageSearch.post/`
    let params = {
      colPackageIds,
      packageName,
      pageNumber: Number(pageNumber),
      pageSize: Number(pageSize)
    }
    return this.post(url, params)
  }
  // banner图获取
  static banner(type) {
    let url = this.urlMap.zhouyu + `/v2/index/banner/${type}`
    return this.get(url)
  }
  // 获取所有省份
  static provinceAll() {
    let url = this.urlMap.prod + `/v2/project/provinceAll.get`
    return this.get(url)
  }
  // 根据城市id查询专业（带模糊查询）
  static project(cityId, type, projectName) {
    let url = this.urlMap.zhouyu + `/v2/project/project.post`
    let params = {
      cityId,
      type,
      projectName
    }
    return this.post(url, params)
  }
  // 游客登录科目列表
  static userProject(projectId, projectName, openId, educationType, cityId) {
    let url = this.urlMap.zhouyu + `/v3/user/visitorSubject?projectId=${projectId}&projectName=${projectName}&openId=${openId}&educationType=${educationType}&cityId=${cityId}`
    return this.get(url)
  }
  static sleepTime(time) {
    return this.sleep(time)
  }
  // 判断用户是否进行过测评
  static userIsEvaluation(openId) {
    let url = `${this.urlMap.zhangyong}/v2/evaluationQuestion/userIsEvaluation/${openId}`
    return this.get(url)
  }
  // 分享落地页领取
  static studyDataRecord (params) {
    let url = this.urlMap.zhouyu + `/studyDataRecord.post`
    return this.post(url, params)
  }
  // 根据分享ID 获取分享者openId
  static studyById (params) {
    let url = this.urlMap.zhouyu + `/studyById.post`
    return this.post(url, params)
  }
  // 发送formId
  static postFormId (params) {
    let url = this.urlMap.zhouyu + `/template/save`
    return this.post(url, params)
  }
}
